package com.lai.note.util;

import android.content.Context;

import com.lai.note.constant.Constant;
import com.lai.note.interceptor.AddCookiesInterceptor;
import com.lai.note.interceptor.ReceivedCookiesInterceptor;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitRequest {


    public static Retrofit getInstance(Context context){
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new AddCookiesInterceptor(context))
                .addInterceptor(new ReceivedCookiesInterceptor(context))
                .build();
        return new Retrofit.Builder()
                .baseUrl(Constant.ROOT_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .client(okHttpClient)
                .build();
    }

}
